<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>jQuery选择器</title>
  <script src="js/jquery-1.11.3.js"></script>
  <style>
    .div_red {
      background-color: red;
    }

    a {
      text-decoration: none;
    }
  </style>
</head>

<body>
  <hr>
  素材: <br>
  <div id="div3">
    <div id="div1" class="div_red">
      <span>11</span>
      <span>22</span>
      <span>33</span>
      <p>44</p>
      <span>55</span>
      <span>66</span>
      <div></div>
      <span>99</span>
    </div>
    <span>77</span>
    <span id="span88" class="div_red">88</span>
    <ul style="list-style: none;">
      <li>l11111111111</li>
      <li>l2</li>
      <li>l3</li>
      <li>l4</li>
      <li>l5</li>
    </ul>
  </div>

  <div>11111112
    <h4>2222222222</h4>
  </div>

  <script>
    console.log("1.id选择器:");
    var $div1 = $("#div1");
    console.log($div1);
    $div1.css("border", "1px solid red");

    console.log("2.类选择器:");
    var $divclass = $(".div_red");
    console.log($divclass);
    $divclass.css("background-color", "green");
    //相当于.style.backGroundColor = "green";

    console.log("3.元素选择器:");
    var $divs = $("div");
    console.log($divs);
    $divs.css("margin-left", "16px");

    console.log("4.通配符选择器:");
    console.log($("*"));

    console.log("5.复合选择器:");
    console.log($("#div1, h4"));

    console.log("6.层次选择器:");
    console.log($("#div3 span"));

    console.log("7.子代选择器:");
    console.log($("#div3>span"));

    console.log("8.兄弟选择器");
    console.log($("li+li"));
    console.log($("li~li"));
    $("li").css("border", "2px solid red");
    //去掉除了第1个外的 上边框
    $("li+li").css("border-top", "0");

    console.log("9.属性过滤选择器");
    console.log($("[id = span88]"));
    console.log($("[id][class=div_red]"));
  </script>
</body>

</html>